package com.hemj.system.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hemj.common.core.domain.R;
import com.hemj.system.domain.SysRegister;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import com.github.pagehelper.Page;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hemj.common.annotation.Log;
import com.hemj.common.core.controller.BaseController;
import com.hemj.common.enums.BusinessType;
import com.hemj.system.vo.SysRegisterVo;
import com.hemj.system.bo.SysRegisterBo;
import com.hemj.system.service.impl.SysRegisterServiceImpl;
import com.hemj.common.utils.poi.ExcelUtil;

/**
 * 系统注册Controller
 * 
 * @author hemj
 * @date 2024-10-21
 */
@Api(tags = "系统注册接口")
@RestController
@RequestMapping("/system/sysRegister")
public class SysRegisterInfoController extends BaseController
{
    @Autowired
    private SysRegisterServiceImpl sysRegisterService;


    /**
     * 获取系统注册详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:sysRegister:query')")
    @PostMapping(value = "/get")
    @ApiOperation("获取系统注册详细信息")
    public R<SysRegister> getInfo()
    {
        SysRegister sysRegister = sysRegisterService.getOne(new LambdaQueryWrapper<>(),false);
        if (sysRegister == null){
            SysRegisterVo sysRegisterVo = new SysRegisterVo();
            sysRegisterVo.setStatus(1);
            sysRegister = sysRegisterService.saveCascade(sysRegisterVo);
        }
        return R.ok(sysRegister);
    }


    /**
     * 修改系统注册
     */
    //@PreAuthorize("@ss.hasPermi('system:sysRegister:edit')")
    @Log(title = "系统注册", businessType = BusinessType.UPDATE)
    @PostMapping(value = "/update")
    @ApiOperation("修改增系统注册")
    public R edit(@RequestBody SysRegisterVo sysRegister)
    {
        sysRegister.setUpdateBy(getNickName());
        sysRegister.setUpdateTime(new Date());
        sysRegister.setStatus(2);
        return R.ok(sysRegisterService.updateCascade(sysRegister));
    }

}
